<template>
	<view class="uni-section" nvue>
		<view v-if="sectionType" class="uni-section__head">
			<view class="lineHeight" :class="isTop?'opacityClass':''"></view>
			<view class="circle uni-section__head-tag" />
			<view class="lineHeight" :class="isBottom?'opacityClass':''"></view>
		</view>
		<!-- <view v-else class="uni-section__head">
			<view class="circle uni-section__head-tag" />
		</view> -->
		<view class="uni-section__content">
			<text :class="{'distraction':!subTitle}" class="uni-section__content-title">{{ title }}</text>
			<text v-if="subTitle" class="uni-section__content-sub">{{ subTitle }}</text>
		</view>
		<slot />
	</view>
</template>

<script>
 /**
  * @description: 步骤条组件/标题组件
  * @param {Boolean} sectionType true-步骤条组件 false-标题组件
  * @param {String} title 标题
  * @param {String} subTitle 副标题
  * @param {Boolean} isTop 去掉第一个步骤条组件左侧线
  * @param {Boolean} isBottom 去掉最后一个步骤条组件左侧线
  * @example: 
  * <uni-section title="步骤条组件"></uni-section>
  */
	export default {
		name: 'sectionLine',
		props: {
			sectionType:{
				type: Boolean,
				default: true
			},
			title: {
				type: String,
				default: ''
			},
			subTitle: {
				type: String,
				default: ''
			},
			isTop:{
				type: Boolean,
				default: false
			},
			isBottom:{
				type: Boolean,
				default: false
			}
		},
		data() {
			return {}
		},
		watch: {
			title(newVal) {
				if (uni.report && newVal !== '') {
					uni.report('title', newVal)
				}
			}
		},
		methods: {
			onClick() {
				this.$emit('click')
			}
		}
	}
</script>
<style lang="scss" scoped>
	.uni-section {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		margin-top: 6px;
		flex-direction: row;
		align-items: center;
		padding: 0 10px;
		height: 50px;
		background-color: $uni-bg-color-grey;
		/* #ifdef APP-NVUE */
		border-bottom-color: $uni-border-color;
		border-bottom-style: solid;
		border-bottom-width: 0.5px;
		/* #endif */
		font-weight: normal;
	}
	/* #ifndef APP-NVUE */
	.uni-section:after {
		position: absolute;
		bottom: 0;
		right: 0;
		left: 0;
		height: 1px;
		content: '';
		-webkit-transform: scaleY(.5);
		transform: scaleY(.5);
		// background-color: $uni-border-color;
	}
	/* #endif */

	.uni-section__head {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-right: 10px;
		overflow: hidden;
	}
	.opacityClass{opacity: 0;}
	.lineHeight{
		width: 1px;
		height:80rpx;
		background:#007aff;
	}

	.circle {
		width: 16rpx;
		height: 16rpx;
		border-radius: 50%;
		background-color: #007aff;
	}

	.uni-section__content {
		flex-direction: column;
		flex: 1;
		color: $uni-text-color;
	}

	.uni-section__content-title {
		font-size: $uni-font-size-base;
		color: $uni-text-color;
	}

	.distraction {
		flex-direction: row;
		align-items: center;
	}

	.uni-section__content-sub {
		font-size: $uni-font-size-sm;
		color: $uni-text-color-grey;
	}
</style>
